#ifndef _RETRO_SCRIPTOR
#define _RETRO_SCRIPTOR

namespace Retro
{
  namespace Creator
  {
    namespace Toolbox
    {
      class Scriptor : public Windows::Window
      {
      private:
        Scripting::ScriptManager mManager;

        WrapWnd         mEdit;
        LayoutElement*  mLayout;
        ToolBar         mToolbar;
        BOOL            mSkipStatus;

      protected:
        virtual VOID  onCreate(Event::WndCreateEvent& iEvent);
        virtual VOID  onDestroy();
        virtual VOID  onSize(Event::SizeEvent& iEvent);
        virtual VOID  onNotify(Event::NotifyEvent& iEvent);
        virtual VOID  onFocus(Event::FocusEvent& iEvent);

        VOID  setStyle(
          INT style,
          DWORD fore = 0xFF000000,
          DWORD back = 0xFFFFFFFF,
          INT size = 0,
          PCCH face = NULL);

      public:
        INL VOID  undo()  { mEdit.send(SCI_UNDO, 0, 0); }
        INL VOID  redo()  { mEdit.send(SCI_REDO, 0, 0); }

        BOOL  runScript();
        BOOL  checkSyntax();

        INL HWND  getEdit()
        {
          return mEdit;
        }

        INL INT   getScriptLength()
        {
          return (INT)mEdit.send(SCI_GETTEXTLENGTH, 0, 0);
        }

        INL VOID  getScript(PCSTR iBuffer, INT iLength)
        {
          mEdit.send(SCI_GETTEXT, iLength, (LPARAM)iBuffer);
        }

        INL VOID  setScript(PCSTR iBuffer)
        {
          mEdit.send(SCI_SETTEXT, NULL, (LPARAM)iBuffer);
        }

        INL VOID  skipStatusChange()
        {
          mSkipStatus = TRUE;
        }

        Scriptor();
        ~Scriptor();
      };
    } // namespace Toolbox
  } // namespace Creator
} // namespace Retro

#endif